package cc.greencat.gcmall.promotion.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import cc.greencat.gcmall.promotion.entity.SecKillSkuRelationEntity;
import cc.greencat.gcmall.promotion.service.SecKillSkuRelationService;
import cc.greencat.gcmall.common.utils.PageUtils;
import cc.greencat.gcmall.common.utils.R;



/**
 * 秒杀活动商品关联
 *
 * @author greencat.cc
 * @email greencatcc@163.com
 * @date 2021-01-11 21:43:44
 */
@RestController
@RequestMapping("promotion/seckillskurelation")
public class SecKillSkuRelationController {
    @Autowired
    private SecKillSkuRelationService secKillSkuRelationService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("promotion:seckillskurelation:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = secKillSkuRelationService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("promotion:seckillskurelation:info")
    public R info(@PathVariable("id") Long id){
		SecKillSkuRelationEntity secKillSkuRelation = secKillSkuRelationService.getById(id);

        return R.ok().put("secKillSkuRelation", secKillSkuRelation);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("promotion:seckillskurelation:save")
    public R save(@RequestBody SecKillSkuRelationEntity secKillSkuRelation){
		secKillSkuRelationService.save(secKillSkuRelation);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("promotion:seckillskurelation:update")
    public R update(@RequestBody SecKillSkuRelationEntity secKillSkuRelation){
		secKillSkuRelationService.updateById(secKillSkuRelation);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("promotion:seckillskurelation:delete")
    public R delete(@RequestBody Long[] ids){
		secKillSkuRelationService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
